home *** CD-ROM | disk | FTP | other *** search
- Path: crl.crl.com!not-for-mail
- From: bobfry@crl.com (Robert Fry)
- Newsgroups: comp.lang.c
- Subject: Re: Is it possible to #include <#defined or -D 'ed macro>?
- Date: 25 Jan 1996 08:32:45 -0800
- Organization: CRL Dialup Internet Access
- Message-ID: <4e8bbd$nl7@crl.crl.com>
- References: <5rbuntgqp0.fsf@ritz.mordor.com>
- NNTP-Posting-Host: crl.com
-
- benjamin@ritz.mordor.com (Joseph Thomas) writes:
-
- >Does anyone know a way of having an include statement that can include
- >a file, based on a -D <MACRO_NAME> flag passed to the compiler, to
- >give the effect of:
-
- >#include <SOURCE>
-
- >cc -D SOURCE=source_a.h
-
- >includes source_a.h
-
- >and
-
- >cc -D SOURCE=source_b.h
-
- >includes source_b.h, (this doesn't seem to work with the xlc compiler)
-
- As far as I know, there's no portable way to do this directly. However,
- you could always use the following when the list of files you might want
- is small and well-defined:
-
- #ifdef SOURCE_A
- #include "source_a.h"
- #endif
- #ifdef SOURCE_B
- #include "source_b.h"
- #endif
- ...
-
- Though in this case, I'd also want some mechanism for recognizing if NO
- file was given and either aborting or otherwise notifying the creator of
- the problem.
-
- Bob
-
-
-